<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello HTTP</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #333;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 2rem;
        }
        
        .container {
            max-width: 700px;
            width: 100%;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            padding: 2.5rem;
            margin-top: 2rem;
        }
        
        header {
            text-align: center;
            margin-bottom: 2rem;
        }
        
        h1 {
            font-size: 2.8rem;
            color: #4a4a4a;
            margin-bottom: 0.5rem;
            background: linear-gradient(to right, #667eea, #764ba2);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .subtitle {
            font-size: 1.2rem;
            color: #666;
            margin-bottom: 1.5rem;
        }
        
        .http-info {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 1.5rem;
            margin-bottom: 2rem;
            border-left: 5px solid #667eea;
        }
        
        .http-info h2 {
            color: #4a4a4a;
            margin-bottom: 1rem;
            font-size: 1.5rem;
        }
        
        .http-info p {
            line-height: 1.6;
            margin-bottom: 1rem;
        }
        
        .demo-section {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 1.5rem;
            margin-bottom: 2rem;
        }
        
        .demo-section h2 {
            color: #4a4a4a;
            margin-bottom: 1rem;
            font-size: 1.5rem;
        }
        
        .request-btn {
            background: linear-gradient(to right, #667eea, #764ba2);
            color: white;
            border: none;
            padding: 0.8rem 1.5rem;
            border-radius: 5px;
            font-size: 1rem;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
            margin-right: 1rem;
            margin-bottom: 1rem;
        }
        
        .request-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
        
        .response-area {
            background: #fff;
            border: 1px solid #ddd;
            border-radius: 5px;
            padding: 1rem;
            margin-top: 1rem;
            min-height: 100px;
            font-family: monospace;
            white-space: pre-wrap;
            overflow-x: auto;
        }
        
        .http-methods {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            margin-bottom: 1.5rem;
        }
        
        .method {
            padding: 0.3rem 0.8rem;
            border-radius: 4px;
            font-weight: bold;
            font-size: 0.9rem;
        }
        
        .get { background: #e7f4e4; color: #2e7d32; }
        .post { background: #e3f2fd; color: #1565c0; }
        
        footer {
            text-align: center;
            margin-top: 2rem;
            color: rgba(255, 255, 255, 0.8);
            font-size: 0.9rem;
        }
        
        @media (max-width: 600px) {
            .container {
                padding: 1.5rem;
            }
            
            h1 {
                font-size: 2.2rem;
            }
            
            .http-methods {
                justify-content: center;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>Hello HTTP</h1>
            <p class="subtitle">了解HTTP协议的基础知识</p>
        </header>
        
        <section class="http-info">
            <h2>什么是HTTP？</h2>
            <p>HTTP（超文本传输协议）是用于传输超媒体文档（如HTML）的应用层协议。它是万维网数据通信的基础。</p>
            <p>HTTP遵循客户端-服务器模型，客户端（通常是Web浏览器）向服务器发起请求，服务器返回响应。</p>
            
            <div class="http-methods">
                <span class="method get">GET</span>
                <span class="method post">POST</span>
            </div>
        </section>
        
        <section class="demo-section">
            <h2>HTTP请求演示</h2>
            <p>点击下面的按钮发送HTTP请求到模拟的API端点：</p>
            
            <button class="request-btn" onclick="sendRequest('GET')">发送GET请求</button>
            <button class="request-btn" onclick="sendRequest('POST')">发送POST请求</button>
            
            <div class="response-area" id="response">
等待请求...
            </div>
        </section>
    </div>
    
    <footer>
        <p>简单的HTTP演示页面 | 使用纯HTML、CSS和JavaScript实现</p>
    </footer>

    <script>
        function sendRequest(method) {
            const responseArea = document.getElementById('response');
            responseArea.textContent = '发送请求中...';
            
            // 模拟网络延迟
            setTimeout(() => {
                let responseText = '';
                
                if (method === 'GET') {
                    responseText = `HTTP/1.1 200 OK
Content-Type: application/json
Date: ${new Date().toUTCString()}

{
  "message": "GET请求成功！",
  "data": {
    "id": 1,
    "name": "示例数据",
    "timestamp": "${new Date().toISOString()}"
  }
}`;
                } else if (method === 'POST') {
                    responseText = `HTTP/1.1 201 Created
Content-Type: application/json
Date: ${new Date().toUTCString()}

{
  "message": "资源创建成功！",
  "id": 12345,
  "createdAt": "${new Date().toISOString()}"
}`;
                }
                
                responseArea.textContent = responseText;
            }, 800);
        }
    </script>
</body>
</html>